<?php

/**
 * ACoreBaseObject
 * CCoreBaseObjectOptions
 *
 * @author Usenko Timur <usenko.timur@gmail.com>
 * @package base
 */

CCore::Using('base.followers');

/**
 * @package base
 */
abstract class ACoreBaseObject
{
	/**
	 * @var CCoreBaseFollowersCollection
	 */
	protected $oFollowers;

	/**
	 * @var CCoreBaseObjectOptions
	 */
	public $ObjectOptions;

	/**
	 * @return ACoreBaseObject
	 */
	public function __construct()
	{
		$this->oFollowers = new CCoreBaseFollowersCollection();
		$this->ObjectOptions = new CCoreBaseObjectOptions();
	}

	/**
	 * @param ICoreBaseFollowers $oFollower
	 * @return void
	 */
	public function AddFollower(ICoreBaseFollowers $oFollower)
	{
		CCore::CheckTypes(array('$oFollower'));
		
		$this->oFollowers->Add($oFollower);
	}
}

/**
 * @package base
 */
class CCoreBaseObjectOptions
{
	/**
	 * @var array
	 */
	protected $aItems;

	/**
	 * @return ACoreBaseObject
	 */
	public function CCoreBaseObjectOptions()
	{
		$this->aItems = array();
	}

	/**
	 * @param string $sName
	 * @return mixed
	 */
	public function __get($sName)
	{
		CCore::CheckTypes(array('$sName'));

		if (key_exists($sName, $this->aItems))
		{
			return $this->aItems[$sName];
		}
		
		return null;
	}

	/**
	 * @param string $sName
	 * @param mixed $mValue
	 * @return void
	 */
	public function __set($sName, $mValue)
	{
		CCore::CheckTypes(array('$sName', '$mValue'));

		if (key_exists($sName, $this->aItems))
		{
			$this->aItems[$sName] = $mValue;
		}
    }

	/**
	 * @param array $aItems
	 * @return void
	 */
	public function InitItems(array $aItems)
	{
		CCore::CheckTypes(array('$aItems'));

		$this->aItems = array_merge($this->aItems, $aItems);
	}
}
